void main()
{

	vec3 N = normalize(gl_NormalMatrix * gl_Normal);
	vec3 L = normalize(vec3(gl_LightSource[0].position));

	float NdotL = max(dot(N, L), 0.0);

	vec4 ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
	vec4 diffuse =  NdotL * (gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse);
	vec4 specular = vec4 (0.0, 0.0, 0.0, 1.0);

	if (NdotL > 0.0) 
	{
		vec3 V = vec3 (-normalize (gl_ModelViewMatrix * gl_Vertex) );
		vec3 R = normalize (reflect(-L, N));
		float RdotV = max(dot(R, V), 0.0);
		specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * pow(RdotV,gl_FrontMaterial.shininess);
	}

	gl_FrontColor = ambient + diffuse + specular;
	
	gl_Position = ftransform();
} 
